// pages/student_index/student_index.ts
const app = getApp<IAppOption>()

Component({
  data: {
    userInfo: {},
    menus: app.globalData.studentMenus || []
  },

  lifetimes: {
    attached() {
      // 获取用户信息
      const userInfo = wx.getStorageSync('userInfo')
      if (userInfo) {
        this.setData({ userInfo })
      } else {
        // 如果未登录，跳转回登录页
        wx.redirectTo({ url: '/pages/login/login' })
      }
    }
  },

  methods: {
    navigateToPage(e: any) {
      const url = e.currentTarget.dataset.url
      wx.navigateTo({ url })
    }
  }
})